package it.blueocean.acanto.taglibrary.jsp.taglib.tags.exceptions;

import it.blueocean.acanto.taglibrary.jsp.taglib.tags.utils.XmlUtils;

import javax.xml.transform.TransformerException;
import org.w3c.dom.Element;

public class ConfigurationException extends Exception
{
	private static final long serialVersionUID = 8475897483953L;

	private String configurationSection_;

	private String configFilePath_;

	public ConfigurationException()
	{
	}

	public ConfigurationException(String paramString)
	{
		super(paramString);
	}

	public ConfigurationException(String paramString, Throwable paramThrowable)
	{
		super(paramString, paramThrowable);
	}

	public ConfigurationException(Throwable paramThrowable)
	{
		super(paramThrowable);
	}

	public ConfigurationException(String paramString, Element paramElement)
	{
		super(paramString);
		setConfigurationSection(paramElement);
	}

	public ConfigurationException(String paramString1, String paramString2, Element paramElement)
	{
		super(paramString1);
		setConfigFilePath(paramString2);
		setConfigurationSection(paramElement);
	}

	public ConfigurationException(String paramString1, Throwable paramThrowable, String paramString2,
			Element paramElement)
	{
		super(paramString1, paramThrowable);
		setConfigFilePath(paramString2);
		setConfigurationSection(paramElement);
	}

	public String toString()
	{
		StringBuffer localStringBuffer = new StringBuffer();
		if(this.configFilePath_ != null)
		{
			localStringBuffer.append("Error in configuration file ");
			localStringBuffer.append(this.configFilePath_);
			localStringBuffer.append("\n");
		}
		localStringBuffer.append("Message: ");
		localStringBuffer.append(getMessage());
		if(this.configurationSection_ != null)
		{
			localStringBuffer.append("\nConfiguration section:\n");
			localStringBuffer.append(this.configurationSection_);
		}
		if(getCause() != null)
		{
			localStringBuffer.append("\nCause:\n");
			localStringBuffer.append(getCause());
		}
		return localStringBuffer.toString();
	}

	public String getConfigFilePath()
	{
		return this.configFilePath_;
	}

	public void setConfigFilePath(String paramString)
	{
		this.configFilePath_ = paramString;
	}

	public String getConfigurationSection()
	{
		return this.configurationSection_;
	}

	public void setConfigurationSection(Element paramElement)
	{
		try
		{
			this.configurationSection_ = XmlUtils.Node2String(paramElement);
		}
		catch (TransformerException localTransformerException)
		{
			this.configurationSection_ = "Error printing configuration section";
		}
	}

	public void setConfigurationSection(String paramString)
	{
		this.configurationSection_ = paramString;
	}
}